#ifndef __IO_FLASH_H__
#define __IO_FLASH_H__

#include "types.h"


#define         SST25VF016B     0x00BF2541        

struct flash_driver {
    void (*init)();
    uint32_t (*open)();
    uint8_t (*erase)(uint32_t sec1, uint32_t sec2);
    int32_t (*write)(uint32_t addr, uint8_t *pdata, uint32_t len);
    int32_t (*read)(uint32_t addr, uint8_t *pdata, uint32_t len); 
};

struct flash_device {
    uint32_t chip_id;   //production id
    struct flash_driver *driver; 
};


bool io_flash_open(struct flash_device *device);
uint32_t io_flash_write(struct flash_device *device, uint32_t addr, 
                    uint8_t *pdata, uint32_t len);
uint32_t io_flash_read(struct flash_device *device, uint32_t addr,
                    uint8_t *pdata, uint32_t len);


#endif